# Template file for 'brave-bin'
pkgname=brave-bin
version=1.48.158
revision=1
only_for_archs="x86_64"
short_desc="Secure, fast and private web browser with ad blocker"
maintainer="privatewright <privateercp@protonmail.com>"
license="MPL-2.0"
homepage="https://brave.com"
distfiles="https://github.com/brave/brave-browser/releases/download/v${version}/brave-browser-${version}-linux-amd64.zip"
checksum=e00938bad3e8ad90e311cab1380df954af624c824bbfcbe581693a7994fe77c7
nostrip=yes

do_extract() {
	mkdir -p ${pkgname}
	bsdtar -xf "${XBPS_SRCDISTDIR}/${pkgname}-${version}/brave-browser-${version}-linux-amd64.zip" -C ${pkgname}
}

do_install() {
	vcopy ${pkgname} usr/lib/
	# Allow firejail users to get suid sandbox working
	chmod 4755 ${DESTDIR}/usr/lib/${pkgname}/chrome-sandbox
	# Install wrapper script
	vbin ${FILESDIR}/${pkgname}.sh brave
	# Install icons
	for size in 16 24 32 48 64 128 256; do
		vmkdir usr/share/icons/hicolor/${size}x${size}/apps
		vinstall ${DESTDIR}/usr/lib/${pkgname}/product_logo_${size}.png 644 usr/share/icons/hicolor/${size}x${size}/apps/ brave-browser.png
	done
	# Install desktop file
	vinstall ${FILESDIR}/brave-browser.desktop 644 usr/share/applications/
	# Remove unused icons
	rm ${DESTDIR}/usr/lib/${pkgname}/*.xpm
	# Remove crontab
	rm -rf ${DESTDIR}/usr/lib/${pkgname}/cron
}
